import { request } from '@/utils/request'

import type { EditableReqData, PageResult } from './model/common'
import type { LoginResult, UserInfoRes, UserReqData } from './model/user'

export function login(username: string, password: string) {
  return request.post<LoginResult>({ url: '/v1/local/login', data: { username, password } })
}
export function getUserInfo(id = '1968257386272886786') {
  return request.get<UserInfoRes>({ url: '/v1/sysUser', params: { id } })
}

export function getUserPageList(page = 1, size = 15) {
  return request.get<PageResult<UserInfoRes>>({ url: '/v1/sysUser/page', params: { page, size } })
}

export function createUser(data: UserReqData) {
  return request.post<void>({ url: '/v1/save/sysUser', data })
}

export function updateUser(data: EditableReqData<UserReqData>) {
  return request.post<void>({ url: '/v1/save/sysUser', data })
}
